package com.example.pc.adapterdemo.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.pc.adapterdemo.R;

public class TabFragment extends Fragment {

    private int titleID;
    private TextView mTextView;

    public static TabFragment newInstance(int param) {
        TabFragment fragment = new TabFragment();
        Bundle args = new Bundle();
        args.putInt("renchunlin", param);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            titleID = getArguments().getInt("renchunlin");
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_tab,null);
        initView(view);
        return view;
    }

    private void initView(View view) {
        mTextView=view.findViewById(R.id.mTextView);
        mTextView.setText(titleID+"");
    }
}
